using System;
using System.Collections.Generic;

namespace AutoChess
{
    public class GameEvent
    {
        private static BEventMgr eventMgr;
        public static void GameEventInit()
        {
            eventMgr = new BEventMgr();
            var logicEvent = new RegisterEventInterface_Logic(eventMgr.GetDispatcher());
            foreach (var inf in logicEvent.m_interfaces)
            {
                eventMgr.RegWrapInterface(inf);
            }
        }

        public static void AddListener(int listenerId, Action listener)
        {
            eventMgr.GetDispatcher().AddListener(listenerId, listener);
        }
        
        public static void AddListener<T>(int listenerId, Action<T> listener)
        {
            eventMgr.GetDispatcher().AddListener(listenerId, listener);
        }
        
        public static void RmvListener(int listenerId, Action callBack)
        {
            eventMgr.GetDispatcher().AddListener(listenerId,callBack);
        }

        public static T Get<T>()
        {
            return eventMgr.GetInterface<T>();
        }
    }
}